package com.qwc.blog.config;

import com.qwc.blog.common.constant.FileConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author qwc
 * @Date 2021/10/26 10:52
 */
@Configuration
public class ResourcesConfig implements WebMvcConfigurer {

    @Autowired
    private FileProperties properties;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /** 本地文件上传路径 */
        registry.addResourceHandler(FileConstant.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + properties.getProfile() + "/");
    }
}
